import DCLib
import json

# input_data = DCLib.RealView.LocalDataNode("file:/Users/zhendu/PycharmProjects/DCLib_driver/testfile.txt")
# output_data = DCLib.RealView.LocalDataNode("")
#
# # add_arr_task = DCLib.RealView.LocalTaskNode("/Users/zhendu/PycharmProjects/DCLib_driver/tmp/python_script_cache/add_arr_local_seq.py")
#
# input_data.task_to_arr.append(add_arr_task)
# output_data.task_from = add_arr_task
#
# add_arr_task.input_data = input_data
# add_arr_task.output_data = output_data
#
# add_arr_task.run()

task_unit = DCLib.Task.init()
input_data_unit = DCLib.Map.init_from("file:/Users/zhendu/study/OSChina/DCLib_driver/testfile.txt")
output_data_unit = DCLib.Map.init_none()

DCLib.Task.OrientDecide.register_seq_op(task_unit, "/Users/zhendu/study/OSChina/DCLib_driver/test123123.ppy", "add")
DCLib.Task.OrientDecide.register_seq_op(task_unit, "/Users/zhendu/study/OSChina/DCLib_driver/test123123.ppy",
                                        "convert_to_int")
DCLib.Task.OrientDecide.register_seq_op(task_unit, "/Users/zhendu/study/OSChina/DCLib_driver/test123123.ppy",
                                        "split_by")
DCLib.Task.OrientDecide.register_seq_op(task_unit, "/Users/zhendu/study/OSChina/DCLib_driver/test123123.ppy", "sub")
DCLib.Task.OrientDecide.register_seq_op(task_unit, "/Users/zhendu/study/OSChina/DCLib_driver/test123123.ppy",
                                        "value_of")
DCLib.Task.OrientDecide.register_seq_op(task_unit, "/Users/zhendu/study/OSChina/DCLib_driver/test123123.ppy",
                                        "key_of")

DCLib.Task.OrientDecide.register_para_op(task_unit, "/Users/zhendu/study/OSChina/DCLib_driver/test123123.ppy",
                                         "split_data")

share = {"iter_time": 0}

# 这里要有一个share
DCLib.Task.Act.build(task_unit, "split_data", share)

# DCLib.run(task_unit, input_data_unit, output_data_unit)
#
# output_data_unit.print_obj()

# 再分割一次，采用递归调用
arr_add_unit = DCLib.Task.init()

DCLib.Task.Observe.set_strategy(arr_add_unit, task_unit)

DCLib.Task.OrientDecide.register_seq_op(arr_add_unit, "/Users/zhendu/study/OSChina/DCLib_driver/test123123.ppy", "add")
DCLib.Task.OrientDecide.register_seq_op(arr_add_unit, "/Users/zhendu/study/OSChina/DCLib_driver/test123123.ppy",
                                        "value_of")
DCLib.Task.OrientDecide.register_seq_op(arr_add_unit, "/Users/zhendu/study/OSChina/DCLib_driver/test123123.ppy",
                                        "key_of")
DCLib.Task.OrientDecide.register_seq_op(arr_add_unit, "/Users/zhendu/study/OSChina/DCLib_driver/test123123.ppy",
                                        "init_a_arr")
DCLib.Task.OrientDecide.register_para_op(arr_add_unit, "/Users/zhendu/study/OSChina/DCLib_driver/test123123.ppy",
                                         "add_1_to_arr")

DCLib.Task.Act.build(arr_add_unit, "add_1_to_arr")

DCLib.run(arr_add_unit, input_data_unit, output_data_unit)

output_data_unit.print_obj()


